package com.yichen.util;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.yichen.music.R;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

public class Home_List_Adapter extends BaseAdapter {

	List<HashMap<String, Object>> data = new ArrayList<HashMap<String, Object>>();
	Context context;

	public Home_List_Adapter(List<HashMap<String, Object>> adapter_data,
			Context context) {
		// TODO Auto-generated constructor stub
		this.data = adapter_data;
		this.context = context;
	}

	public int getCount() {
		// TODO Auto-generated method stub
		return data.size();
	}

	public Object getItem(int position) {
		// TODO Auto-generated method stub
		return null;
	}

	public long getItemId(int position) {
		// TODO Auto-generated method stub
		return position;
	}

	public View getView(int position, View convertView, ViewGroup parent) {
		// TODO Auto-generated method stub

		LayoutInflater inflater = (LayoutInflater) context
				.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
		View view = inflater.inflate(R.layout.list_item_home, null);
		ImageView left_img = (ImageView) view.findViewById(R.id.img_left);
		TextView name_text_view = (TextView) view.findViewById(R.id.name_text);
		left_img.setImageResource((Integer) data.get(position).get("img"));
		name_text_view.setText((String) data.get(position).get("name"));

		return view;
	}
}
